Command Handlers
Command handlers are handlers for application commands. They are similar to subroutine handlers, but instead of defining responses to user-defined commands, they define responses to application commands, such as Open, Print, or Move, sent to application objects.You define command handlers in scripts, but they handle commands that are sent to application objects. To be useful, scripts that contain command handlers must be associated with the application objects that receive those commands. This is called attaching a script to an application object.
Scripts that are attached to objects can change the way those objects respond to particular commands. Each application determines which, if any, of its objects can have attached scripts, and how you attach the scripts.
This section describes the syntax for command handler definitions. For information about recursion in command handlers, see the"Recursive Subroutines," which begins on page 225. For information about the scope
of variables and properties in handlers, see "Scope of Script Variables and Properties," which begins on page 252.